/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pio.action.administrador.paradas;

import DBMS.DataBaseManager;
import java.util.List;
import clases.Parada;
import clases.Turno;
import clases.Preinscrito;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.Action;
/**
 *
 * @author Owner
 */
public class Listar extends Action {
    
    /* forward name="success" path="" */
    private static final String SUCCESS = "success";
    private static final String FAILURE = "failure";

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        DataBaseManager dbms = DataBaseManager.getInstance();
        Preinscrito pre1= new Preinscrito();
        Preinscrito pre2= new Preinscrito();
        Preinscrito pre3= new Preinscrito();
        List instituciones= dbms.consultarInstituciones();
        List <Turno> turnos= dbms.consultarTurno(new Turno());
        List <Parada> paradas1=dbms.obtenerParadasDeTurno(turnos.get(0));
        List <Parada> paradas2=dbms.obtenerParadasDeTurno(turnos.get(1));
        List <Parada> paradas3=dbms.obtenerParadasDeTurno(turnos.get(2));
        List preinscritos1=dbms.obtenerNumeroPreinscritosDeTurno(turnos.get(0));
        List preinscritos2=dbms.obtenerNumeroPreinscritosDeTurno(turnos.get(1));
        List preinscritos3=dbms.obtenerNumeroPreinscritosDeTurno(turnos.get(2));
        request.setAttribute("turnos",turnos);
        request.setAttribute("paradas1",paradas1);
        request.setAttribute("paradas2",paradas2);
        request.setAttribute("paradas3",paradas3);
        request.setAttribute("preinscritos1",preinscritos1);
        request.setAttribute("preinscritos2",preinscritos2);
        request.setAttribute("preinscritos3",preinscritos3);
        return mapping.findForward(SUCCESS);
    }
}
